<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="" lay-filter="orderForm" >
    <div class="layui-form-item" style="margin-top:10px">
        <div class="layui-inline">
            <label class="layui-form-label">员工姓名</label>
            <div class="layui-input-block" style="width:200px">
                <input type="text" id="name" name="name" lay-verify="name" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">员工性别：</label>
            <div class="layui-input-block">
                <select class="layui-form-select" name="city" lay-verify="required">
                    <option value="">---请选择---</option>
                    <option value="0">男</option>
                    <option value="1">女</option>

                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">部门：</label>
            <div class="layui-input-block">
                <select class="layui-form-select" name="city" lay-verify="required">
                    <option value="">--- 请选择 ---</option>
                    <option value="0"></option>
                    <option value="1"></option>
                    <option value="2"></option>
                    <option value="3"></option>
                    <option value="4"></option>
                </select>
            </div>
        </div>
        <button type="button" id="formSubmit" class="layui-inline layui-btn" lay-submit="" lay-filter="query">查询</button>
    </div>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<script src="https://www.layuicdn.com/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.min.js"></script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use(['table','form','jquery','layer'], function(){
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;

        table.render({
            id : 'departmentTable'
            ,elem: '#test'
            ,url:'/firstWeb/employee/queryAll'
            ,title: '用户数据表'
            ,where: {}
            ,cols: [[
                //"id":1,"partId":1,"loginName":"botao","password":"123",
                // "img":"upfile/nan1.jpg","gender":"男","flag":1,"admin":1,
                // "remark":"员工1","trueName":"赵波涛","is":1
                {field:'id', title:'员工编号'}
                ,{field:'partId', title:'部门编号(外键)'}
                ,{field:'loginName', title:'登陆名'}
                ,{field: 'password', title:'登陆密码'}
                ,{field:'img', title:'员工图片'}
                ,{field:'gender', title:'员工性别'}
                ,{field: 'flag', title:'员工级别'}
                ,{field:'admin', title:'员工操作系统级别'}
                ,{field: 'trueName', title:'员工真实姓名'}
                ,{field: 'is', title:'员工状态'}
                ,{field: 'right', title:'操作', toolbar: '#barDemo'}
            ]]
            ,page: true // 默认一页十条
            ,limit:5
            ,limits: [1,5,10,20]
        });

        $("#formsubmit").click(function(){
            table.reload('departmentTable',{
                where : data
                ,page: {
                    curr: 1
                }
            })
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>

</body>
</html>